import request from "@/utils/request";

// 获取订单页信息
export const reqGetTradeInfo = () => {
  return request({
    method: "GET",
    url: `/order/auth/trade`,
  });
};

// center页面：获取订单分页列表
export const reqGetTradeList = (page, limit) => {
  return request({
    method: "GET",
    url: `/order/auth/${page}/${limit}`,
  });
};

// 提交订单，得到订单号
export const reqSubmitOrder = ({
  consignee,
  consigneeTel,
  deliveryAddress,
  paymentWay,
  orderComment,
  orderDetailList,
  tradeNo,
}) => {
  return request({
    method: "POST",
    url: `/order/auth/submitOrder`,
    params: {
      // querystring
      tradeNo,
    },
    data: {
      // body
      consignee,
      consigneeTel,
      deliveryAddress,
      paymentWay,
      orderComment,
      orderDetailList,
    },
  });
};

// 根据订单号获取支付二维码
export const reqGetQRCode = (orderId) => {
  return request({
    method: "GET",
    url: `/payment/weixin/createNative/${orderId}`,
  });
};

// 查询订单支付状态
export const reqQueryPayStatus = (orderId) => {
  return request({
    method: "GET",
    url: `/payment/weixin/queryPayStatus/${orderId}`,
  });
};
